/**
 */
package fUML.Semantics.Actions.CompleteActions.impl;

import fUML.Semantics.Actions.BasicActions.impl.ActionActivationImpl;

import fUML.Semantics.Actions.CompleteActions.AcceptEventActionActivation;
import fUML.Semantics.Actions.CompleteActions.AcceptEventActionEventAccepter;
import fUML.Semantics.Actions.CompleteActions.CompleteActionsPackage;

import fUML.Semantics.CommonBehaviors.Communications.SignalInstance;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Accept Event Action Activation</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link fUML.Semantics.Actions.CompleteActions.impl.AcceptEventActionActivationImpl#getEventAccepter <em>Event Accepter</em>}</li>
 *   <li>{@link fUML.Semantics.Actions.CompleteActions.impl.AcceptEventActionActivationImpl#isWaiting <em>Waiting</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class AcceptEventActionActivationImpl extends ActionActivationImpl implements AcceptEventActionActivation {
	/**
	 * The cached value of the '{@link #getEventAccepter() <em>Event Accepter</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEventAccepter()
	 * @generated
	 * @ordered
	 */
	protected AcceptEventActionEventAccepter eventAccepter;

	/**
	 * The default value of the '{@link #isWaiting() <em>Waiting</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isWaiting()
	 * @generated
	 * @ordered
	 */
	protected static final boolean WAITING_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isWaiting() <em>Waiting</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isWaiting()
	 * @generated
	 * @ordered
	 */
	protected boolean waiting = WAITING_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected AcceptEventActionActivationImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return CompleteActionsPackage.Literals.ACCEPT_EVENT_ACTION_ACTIVATION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public AcceptEventActionEventAccepter getEventAccepter() {
		if (eventAccepter != null && eventAccepter.eIsProxy()) {
			InternalEObject oldEventAccepter = (InternalEObject)eventAccepter;
			eventAccepter = (AcceptEventActionEventAccepter)eResolveProxy(oldEventAccepter);
			if (eventAccepter != oldEventAccepter) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, CompleteActionsPackage.ACCEPT_EVENT_ACTION_ACTIVATION__EVENT_ACCEPTER, oldEventAccepter, eventAccepter));
			}
		}
		return eventAccepter;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public AcceptEventActionEventAccepter basicGetEventAccepter() {
		return eventAccepter;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetEventAccepter(AcceptEventActionEventAccepter newEventAccepter, NotificationChain msgs) {
		AcceptEventActionEventAccepter oldEventAccepter = eventAccepter;
		eventAccepter = newEventAccepter;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CompleteActionsPackage.ACCEPT_EVENT_ACTION_ACTIVATION__EVENT_ACCEPTER, oldEventAccepter, newEventAccepter);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setEventAccepter(AcceptEventActionEventAccepter newEventAccepter) {
		if (newEventAccepter != eventAccepter) {
			NotificationChain msgs = null;
			if (eventAccepter != null)
				msgs = ((InternalEObject)eventAccepter).eInverseRemove(this, CompleteActionsPackage.ACCEPT_EVENT_ACTION_EVENT_ACCEPTER__ACTION_ACTIVATION, AcceptEventActionEventAccepter.class, msgs);
			if (newEventAccepter != null)
				msgs = ((InternalEObject)newEventAccepter).eInverseAdd(this, CompleteActionsPackage.ACCEPT_EVENT_ACTION_EVENT_ACCEPTER__ACTION_ACTIVATION, AcceptEventActionEventAccepter.class, msgs);
			msgs = basicSetEventAccepter(newEventAccepter, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, CompleteActionsPackage.ACCEPT_EVENT_ACTION_ACTIVATION__EVENT_ACCEPTER, newEventAccepter, newEventAccepter));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isWaiting() {
		return waiting;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setWaiting(boolean newWaiting) {
		boolean oldWaiting = waiting;
		waiting = newWaiting;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, CompleteActionsPackage.ACCEPT_EVENT_ACTION_ACTIVATION__WAITING, oldWaiting, waiting));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void accept(SignalInstance signalInstance) {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean match(SignalInstance signalInstance) {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case CompleteActionsPackage.ACCEPT_EVENT_ACTION_ACTIVATION__EVENT_ACCEPTER:
				if (eventAccepter != null)
					msgs = ((InternalEObject)eventAccepter).eInverseRemove(this, CompleteActionsPackage.ACCEPT_EVENT_ACTION_EVENT_ACCEPTER__ACTION_ACTIVATION, AcceptEventActionEventAccepter.class, msgs);
				return basicSetEventAccepter((AcceptEventActionEventAccepter)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case CompleteActionsPackage.ACCEPT_EVENT_ACTION_ACTIVATION__EVENT_ACCEPTER:
				return basicSetEventAccepter(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case CompleteActionsPackage.ACCEPT_EVENT_ACTION_ACTIVATION__EVENT_ACCEPTER:
				if (resolve) return getEventAccepter();
				return basicGetEventAccepter();
			case CompleteActionsPackage.ACCEPT_EVENT_ACTION_ACTIVATION__WAITING:
				return isWaiting();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case CompleteActionsPackage.ACCEPT_EVENT_ACTION_ACTIVATION__EVENT_ACCEPTER:
				setEventAccepter((AcceptEventActionEventAccepter)newValue);
				return;
			case CompleteActionsPackage.ACCEPT_EVENT_ACTION_ACTIVATION__WAITING:
				setWaiting((Boolean)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case CompleteActionsPackage.ACCEPT_EVENT_ACTION_ACTIVATION__EVENT_ACCEPTER:
				setEventAccepter((AcceptEventActionEventAccepter)null);
				return;
			case CompleteActionsPackage.ACCEPT_EVENT_ACTION_ACTIVATION__WAITING:
				setWaiting(WAITING_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case CompleteActionsPackage.ACCEPT_EVENT_ACTION_ACTIVATION__EVENT_ACCEPTER:
				return eventAccepter != null;
			case CompleteActionsPackage.ACCEPT_EVENT_ACTION_ACTIVATION__WAITING:
				return waiting != WAITING_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (waiting: ");
		result.append(waiting);
		result.append(')');
		return result.toString();
	}

} //AcceptEventActionActivationImpl
